package com.bw.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.bw.bean.Clazz;
import com.bw.bean.addBean.Classes;
import com.bw.bean.addBean.Student;
import com.bw.bean.addBean.Teachers;
import com.bw.bean.addBean.TestReturn;
import com.bw.dao.AddDAO;
import com.bw.dao.ClassDao;
import com.bw.service.AddService;
import com.bw.util.PageUtil;




@Repository
public class AddServiceImpl implements AddService{
	
	@Autowired
	private AddDAO addDao;
	
	@Autowired
	private  ClassDao  clazzdao;
	
	public List<TestReturn> getClasses() throws Exception {
		// TODO Auto-generated method stub
		return addDao.getClasses();
	}

	public List<TestReturn> getTeacher() throws Exception {
		// TODO Auto-generated method stub
		return addDao.getTeacher();
	}

	public int doAddStudent(Student student) throws Exception {
		// TODO Auto-generated method stub
		return addDao.doAddStudent(student);
	}

	public int doAddClasses(Classes classes) throws Exception {
		// TODO Auto-generated method stub
		return addDao.doAddClasses(classes);
	}

	public int doAddTeachers(Teachers teachers) throws Exception {
		// TODO Auto-generated method stub
		return addDao.doAddTeachers(teachers);
	}

	public List<Teachers> getListTeacher(PageUtil page) {
		// TODO Auto-generated method stub
		List<Teachers> listTeacher = addDao.getListTeacher(page);
		for (Teachers teachers : listTeacher) {
			Integer type = teachers.getType();
			if(type==null){
				
			}else{
				
			
			if(type==1){
				teachers.setType_("讲师");
			}else if(type==2){
				teachers.setType_("班主任");
			}else if(type==3){
				teachers.setType_("主任");
			}
			}
		}
		return listTeacher;
	}

	/*public List<Classes> getListClasses(PageUtil pageUtil) {
		// TODO Auto-generated method stub
		List<Classes> listClasses = addDao.getListClasses(pageUtil);
		for (Classes classes : listClasses) {
			Integer status = classes.getStatus();
			if(status==null){
				
			}else{
				
			
			if(status==1){
				classes.setStatus_("当期");
			}else if(status==2){
				classes.setStatus_("以往");
			}else if(status==3){
				classes.setStatus_("返回");
			}
			}
			
		}
		
		return listClasses;
	}*/

	public int getCountByTeachers() {
		return addDao.getCountByTeachers();
	}

	public int getCountByClasses() {
		// TODO Auto-generated method stub
		return addDao.getCountByClasses();
	}

	public int getCountByStudent() {
		// TODO Auto-generated method stub
		return addDao.getCountByStudent();
	}


	/*public List<Student> getListStudent(PageUtil pageUtil) {
		// TODO Auto-generated method stub
		List<Student> listStudent = addDao.getListStudent(pageUtil);
		for (Student student : listStudent) {
			System.out.println(student.getSname());
		}
		
		for (Student student : listStudent) {
			if(student.getCall_status()==null){
			}else if(student.getCall_status()==1){
				student.setCall_status_("就业");
			}else if(student.getCall_status()==2){
				student.setCall_status_("未就业");
			}
			
			if(student.getCall_status()==null){
			}else if(student.getCall_status()==1){
				student.setCall_status_("正常");
			}else if(student.getCall_status()==2){
				student.setCall_status_("失联");
			}
			
		}
		return listStudent;
	}*/

	public List<Student> getListStudent(PageUtil pageUtil, Integer tid) {
		// TODO Auto-generated method stub
		List<Student> listStudent = addDao.getListStudent(pageUtil.getPageindex(), pageUtil.getPagesize(), tid);
		for (Student student : listStudent) {
			System.out.println(student.getSname());
		}
		
		for (Student student : listStudent) {
			if(student.getCall_status()==null){
			}else if(student.getCall_status()==1){
				student.setCall_status_("就业");
			}else if(student.getCall_status()==2){
				student.setCall_status_("未就业");
			}
			
			if(student.getCall_status()==null){
			}else if(student.getCall_status()==1){
				student.setCall_status_("正常");
			}else if(student.getCall_status()==2){
				student.setCall_status_("失联");
			}
		}
		return listStudent;
	}

	public List<Classes> getListClasses(PageUtil pageUtil, Integer tid) {
		List<Classes> listClasses = addDao.getListClasses(pageUtil.getPageindex(), pageUtil.getPagesize(), tid);
		for (Classes classes : listClasses) {
			Integer status = classes.getStatus();
			if(status==null){
				
			}else{
				
			
			if(status==1){
				classes.setStatus_("当期");
			}else if(status==2){
				classes.setStatus_("以往");
			}else if(status==3){
				classes.setStatus_("返回");
			}
			}
			
		}
		
		return listClasses;
	}

	public Clazz getClazzByClazzName(String cname) {
		
		return clazzdao.getClazzByClazzName(cname);
	}

	
}
